package tedu.week04.day02_thread.lesson5;

/**
 * <pre>
 *      异常终止.
 * </pre>
 *
 * @author : resty
 * @date : 2019年07月09日    16时
 **/
public class StopThread {
    public static void main(String[] args) throws InterruptedException {
      StopTest st = new StopTest();
      Thread t = new Thread(st,"线程");
      t.start();
      Thread.sleep(10);
      st.stop();
    }
}
class StopTest implements Runnable {
    private boolean flag =true;
    @Override
    public void run() {
        int i = 0 ;
        while(flag){
            System.out.println(Thread.currentThread().getName()+i++);
        }
    }
    public void stop(){
        flag=false;
    }
}